package com.ubi.app.dao;

import static org.apache.ibatis.jdbc.SqlBuilder.BEGIN;
import static org.apache.ibatis.jdbc.SqlBuilder.INSERT_INTO;
import static org.apache.ibatis.jdbc.SqlBuilder.SET;
import static org.apache.ibatis.jdbc.SqlBuilder.SQL;
import static org.apache.ibatis.jdbc.SqlBuilder.UPDATE;
import static org.apache.ibatis.jdbc.SqlBuilder.VALUES;
import static org.apache.ibatis.jdbc.SqlBuilder.WHERE;

import com.ubi.app.domain.Position;

public class PositionSqlProvider {

    public String insertSelective(Position record) {
        BEGIN();
        INSERT_INTO("position");
        
        if (record.getId() != null) {
            VALUES("id", "#{id,jdbcType=BIGINT}");
        }
        
        if (record.getLongtitude() != null) {
            VALUES("longtitude", "#{longtitude,jdbcType=DECIMAL}");
        }
        
        if (record.getLatitude() != null) {
            VALUES("latitude", "#{latitude,jdbcType=DECIMAL}");
        }
        
        if (record.getName() != null) {
            VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getBizId() != null) {
            VALUES("biz_id", "#{bizId,jdbcType=VARCHAR}");
        }
        
        if (record.getBizType() != null) {
            VALUES("biz_type", "#{bizType,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            VALUES("create_time", "#{createTime,jdbcType=TIMESTAMP}");
        }
        
        return SQL();
    }

    public String updateByPrimaryKeySelective(Position record) {
        BEGIN();
        UPDATE("position");
        
        if (record.getLongtitude() != null) {
            SET("longtitude = #{longtitude,jdbcType=DECIMAL}");
        }
        
        if (record.getLatitude() != null) {
            SET("latitude = #{latitude,jdbcType=DECIMAL}");
        }
        
        if (record.getName() != null) {
            SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getBizId() != null) {
            SET("biz_id = #{bizId,jdbcType=VARCHAR}");
        }
        
        if (record.getBizType() != null) {
            SET("biz_type = #{bizType,jdbcType=VARCHAR}");
        }
        
        if (record.getCreateTime() != null) {
            SET("create_time = #{createTime,jdbcType=TIMESTAMP}");
        }
        
        WHERE("id = #{id,jdbcType=BIGINT}");
        
        return SQL();
    }
}